<?php
/**
 * 个人作品，学习使用
 * 入口文件
 * svn pass mP9mG7Bx5VN7
 * http://t.sina.com.cn/mogood 
 * @author 唐共军 speechtang@gmail.com
 */
$debug = true;
date_default_timezone_set('Asia/Shanghai');
if ($debug)
{
    ini_set('display_errors', 'On');
    error_reporting(E_ALL);
}
else
{
    ini_set('display_errors', 'Off');
}
require_once("class/chess.class.php");
require_once("controller/chess.class.php");
require_once("module/chess.class.php");

if (empty($_POST['act']))
{
    $result = array(
        "result" => 'fail',
        'reason' => 'empty action'
    );  
}
else
{
    $action   = $_POST['act'];
    $cls_ctrl = new controller_chess();
    if (!$result = $cls_ctrl->$action())
    {
        $result = array(
            "result" => 'fail',
            'reason' => 'app error'
        );
    }
}
die(json_encode($result));
